package 线程.day3.demo2;

public class Sell implements Runnable{
    static int num=1000;

    @Override
    public void run() {
        while (num>0){

            //synchronized (Sell.class){
            synchronized (this){
                if(num<=0){
                    break;
                }
                System.out.println(Thread.currentThread().getName()+"卖出票："+num);
                num--;
            }
            Thread.yield();
//            try {
//                Thread.sleep(1);
//            } catch (InterruptedException e) {}
        }
    }
}
